import { Button, VerticalBox } from "std-widgets.slint";
import { LoginPage } from "login_page.slint";
import { HomePage } from "home_page.slint";

enum Page {
    Login,
    Home,
}

export component AppWindow inherits Window {
    in-out property <Page> current_page: Page.Login;
    callback login(string, string) -> bool;

    width: 360px;
    height: 240px;
    title: "Zechat";

    if (current_page == Page.Login): LoginPage {
        width: parent.width;
        height: parent.height;
        visible: current_page == Page.Login;
        login(username, password) => {
            if root.login(username, password) {
                current_page = Page.Home
            }
        }
    }

    if (current_page == Page.Home): HomePage {
        width: parent.width;
        height: parent.height;
        visible: current_page == Page.Home;
    }
}
